<!--
  This file is a part of the open-eBackup project.
  This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
  If a copy of the MPL was not distributed with this file, You can obtain one at
  http://mozilla.org/MPL/2.0/.
  
  Copyright (c) [2024] Huawei Technologies Co.,Ltd.
  
  THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
  EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
  MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
  -->

<lv-form [formGroup]="formGroup" class="formGroup">
  <lv-form-item>
    <lv-form-label lvRequired>{{
      'common_ip_domain_name_label' | i18n
    }}</lv-form-label>
    <lv-form-control>
      <div formArrayName="ip">
        <div
          *ngFor="let ip of ipArr; let i = index; last as isLast"
          [ngClass]="{ 'mgb-ip': !isLast, 'last-mgb-ip': isLast }"
        >
          <lv-form-control
            [lvErrorTip]="baseUtilService.ipErrorTip"
            class="ips-control"
          >
            <lv-group [lvColumns]="['auto', '25px']">
              <input lv-input type="text" [formControlName]="i" />
              <div class="aui-link" *ngIf="ipArr.length > 1">
                <i
                  lv-icon="lv-icon-remove"
                  lvColorState="true"
                  (click)="deleteIp(i)"
                  lv-tooltip="{{ 'common_delete_label' | i18n }}"
                ></i>
              </div>
            </lv-group>
          </lv-form-control>
        </div>
      </div>
      <div class="tips" *ngIf="ipRepeat">
        <i lv-icon="lv-icon-status-failed" class="error-icon"></i>
        {{ repeatTips }}
      </div>
      <div class="aui-link">
        <span (click)="addIp()">
          <i lv-icon="aui-icon-create" class="add-ip-icon"></i>
          {{ 'common_add_label' | i18n }}
        </span>
      </div>
    </lv-form-control>
  </lv-form-item>
  <lv-form-item>
    <lv-form-label lvRequired>{{ 'common_port_label' | i18n }}</lv-form-label>
    <lv-form-control [lvErrorTip]="portErrorTip">
      <input
        lv-input
        lv-input
        type="text"
        formControlName="port"
        placeholder="1~65535"
      />
    </lv-form-control>
  </lv-form-item>
  <lv-form-item>
    <lv-form-label lvRequired>{{
      'common_username_label' | i18n
    }}</lv-form-label>
    <lv-form-control [lvErrorTip]="nameErrorTip">
      <input lv-input type="text" formControlName="username" />
    </lv-form-control>
  </lv-form-item>
  <lv-form-item>
    <lv-form-label lvRequired>{{
      'common_password_label' | i18n
    }}</lv-form-label>
    <lv-form-control>
      <aui-inupt-with-eye formControlName="password"></aui-inupt-with-eye>
    </lv-form-control>
  </lv-form-item>
</lv-form>
